package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.mapper.OrderMapper;
import com.itheima.pojo.Order;
import com.itheima.pojo.OrderMemberVo;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    //分页查找
    public PageResult findPage(QueryPageBean queryPage) {
        //设置分页参数
        PageHelper.startPage(queryPage.getCurrentPage(), queryPage.getPageSize());

        List<OrderMemberVo> page = orderMapper.findPage(queryPage);

        Page<OrderMemberVo> p = (Page<OrderMemberVo>) page;
        return new PageResult(p.getTotal(), p.getResult());
    }

    //修改预约状态
    public void update(Order order) {
        orderMapper.update(order);
    }


}
